<template>
    <div class="app-container">
        <!-- 基础信息 -->
        <h5 class="titleInfo">
            基础信息
        </h5>
        <el-form class="form" ref="form" :model="form" :rules="rules" label-width="130px">
            <el-row>
                <el-col :span="12">
                    <el-form-item label="手机号" prop="username">
                        <el-input v-model="form.username"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="昵称" prop="nickName">
                        <el-input v-model="form.nickName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="姓名">
                        <span class="spanToInput">{{form.realName | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="交钱分公司">
                        <span class="spanToInput">{{form.branchName | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="级别">
                        <span class="spanToInput">{{form.roleName | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="账户类型">
                         <span class="spanToInput">{{form.type | typeNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="加盟金额" prop="joinAmount">
                        <!-- <el-input v-model="valnew"></el-input>  -->
                        <el-input v-model="form.joinAmount"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        <!-- 推荐人信息 -->
        <div class="divBar"></div>
        <h5 class="titleInfo">
            推荐人信息
        </h5>

            <el-row>
                <el-col :span="12">
                    <el-form-item label="推荐人姓名">
                        <span class="spanToInput">{{list.referName | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="推荐人手机号">
                        <span class="spanToInput">{{list.referPhone | filterNull}}</span>
                    </el-form-item>
                </el-col>
            </el-row>

        <!-- 实名认证信息 -->
        <div class="divBar"></div>
        <h5 class="titleInfo">
            实名认证信息
        </h5>

            <el-row>
                <el-col :span="12">
                    <el-form-item label="证件类型">
                        <span>{{form.cardType | cardNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="推荐人手机号">
                        <span class="spanToInput">{{form.card | filterNull}}</span>
                    </el-form-item>
                </el-col>
            </el-row>

        <!-- 银行卡信息 -->
        <div class="divBar"></div>
        <h5 class="titleInfo">
            银行卡信息
        </h5>

            <el-row>
                <el-col :span="12">
                    <el-form-item label="银行名称">
                        <span class="spanToInput">{{list.banksDTOList.name | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="银行卡号">
                        <span class="spanToInput">{{list.banksDTOList.card | filterNull}}</span>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-form-item>
                <el-button type="primary" @click="submitFn('form')" >立即提交</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
import { getList,getInfo,modifyUserServerInfo} from '@/api/designerManage'
export default {
    name:"designerManageEdit",
    data(){
        return {
            form:{},
            list:{
                referName:"",
                referPhone:"",
                banksDTOList:{
                    name:"",
                    card:""
                }
            },
            rules: {
                username: [
                    { required: true, message: '请输入手机号', trigger: 'blur' }
                ],
                joinAmount : [
                    { required: true, message: '请输入加盟金额', trigger: 'blur' }
                ]
            },
            userId:null,
        }
    },
    created(){
        this.form = JSON.parse(this.$route.query.userId)
        this.userId = this.form.userId
    },
    filters:{
        filterNull(e) {
            if(!e){
                return "暂无"
            }else{
                return e
            }
        },
        cardNull(e){
            return window.helper.cardType(String(e))
        },
        typeNull(e){
            return window.helper.accountType(String(e))
        }
    },
    methods:{
        submitFn(e){
            this.$refs[e].validate((valid) => {
                if (valid) {
                    let datas = this.form
                    modifyUserServerInfo(datas).then(res=>{
                        if(!res.data.code){
                            this.$message({
                                showClose: true,
                                message: '修改成功',
                                type: 'success'
                            });
                            this.$router.push('/designerManageIndex')
                        }else{
                            this.$message({
                                showClose: true,
                                message: res.data.msg,
                                type: 'warning'
                            });
                        }
                    })
                    .catch(error =>{
                        this.$message.error(error);
                    })
                }else{
                     this.$message({
                        message: '有必填项没填，不能提交咯',
                        type: 'warning'
                    });
                    return false;
                }
            });
        }
    }
}
</script>
<style scoped>
.app-container{padding: 0px!important}
</style>

